<div class="row m-n">
    <div class="crumbs-bar">
        <div yb-crumbs></div>
    </div>
    <div tabset type="tab">
        <div tab heading="发票管理" active="activeFlag[0]" ng-click="changeTab(0)">
            <div class="row wrapper-y-sm">
                <div class="operate-bar col-xs-4 font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="updateSAP()" ng-disabled="!btnPermission.updateSAP" title="{{!btnPermission.updateSAP?'无权限执行此操作':''}}">更新SAP</button>
                    <button ng-if="isWJ" class="btn btn-operate m-r-sm" ng-click="syncContractNumber()" >纸质合同号同步</button>
                    <button ng-if="isDL || isZHL" class="btn btn-operate m-r-sm" ng-click="syncSAPHistory()" >SAP历史数据同步</button>
                </div>
                <div class="search-bar wrapper-none col-xs-8">
                    <div class="btn-group m-l-xs pull-right">
                        <button type="button" class="btn btn-default base-color" ng-click="search()" title="刷新">
                            <i class="yb-icon ico-refresh"></i>
                        </button>
                        <button type="button" class="btn btn-default base-color" title="配置表格列"
                                ng-click="switchToolbar('ColConfig');">
                            <i class="yb-icon ico-set"></i>
                        </button>
                        <div class="btn btn-default base-color" ng-if="!!btnPermission.invoiceExport">
                            <div title="导出">
                                <i class="yb-icon ico-export-o"></i>
                            </div>
                            <ul class="more-tool">
                                <li yb-download download-url="exportParam.sectionUrl"
                                    download-param="exportParam.sectionParam"
                                    download-key="ids">
                                    <i class="yb-icon ico-export-o"></i> 导出
                                </li>
                                <li yb-download download-url="exportParam.allUrl" download-param="condition" download-duration="3">
                                    <i class="yb-icon ico-export-o"></i> 导出全部
                                </li>
                            </ul>
                        </div>
                    </div>
                    <button class="btn-advance pull-right m-l-xs" ng-click="switchToolbar('AdvanceSearch')">高级搜索
                    </button>
                    <div class="input-group pull-right clearfix">
                        <input type="text" class="form-control txt-search" placeholder="开票凭证"
                               ng-model="condition.invoiceNo">
                        <span class="input-group-addon cursor-pointer" ng-click="search(1)">搜索</span>
                    </div>
                </div>
                <div yb-advance-search show-toolbar="toolbarConfig.showAdvanceSearch" search-data="search(1)"
                     reset-data="reset()">
                    <div class="advance-search m-t-sm">
                        <div class="form-group clearfix">
                            <label class="control-label">开票凭证：</label>
                            <input type="text" ng-model="condition.invoiceNo" class="form-control">
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">纸质发票号：</label>
                            <input type="text" ng-model="condition.invoicePaperNo" class="form-control">
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">付款方：</label>
                            <input type="text" ng-model="condition.payerOrgName" class="form-control">
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label">是否签收：</label>
                            <select name="reverseStatus" class="form-control" ng-model="condition.isSign">
                                <option value="">请选择</option>
                                <option value=0>否</option>
                                <option value=1>是</option>
                            </select>
                        </div>
                        <div class="form-group clearfix m-b-none">
                            <label class="control-label">创建时间：</label>
                            <input type="text" class="form-control date-picker" ng-model="condition.createDateStart"
                                   datepicker-popup="{{'yyyy-MM-dd'}}"
                                   ng-click="showOrderDateStart = !showOrderDateStart"
                                   ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')"
                                   is-open="showOrderDateStart" close-text="关闭" modal-size="small" readonly>
                        </div>
                        <div class="form-group clearfix m-b-none">
                            <label class="control-label"></label>
                            <label class="control-label wave-line">~</label>
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label"></label>
                            <input type="text" class="form-control date-picker" ng-model="condition.createDateEnd"
                                   datepicker-popup="{{'yyyy-MM-dd'}}"
                                   ng-click="showOrderDateEnd = !showOrderDateEnd"
                                   ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')"
                                   is-open="showOrderDateEnd" close-text="关闭" modal-size="small" readonly>
                        </div>
                        <div class="form-group clearfix m-b-none">
                            <label class="control-label">签收时间：</label>
                            <input type="text" class="form-control date-picker" ng-model="condition.signDateStart"
                                   datepicker-popup="{{'yyyy-MM-dd'}}"
                                   ng-click="showSignDateStart = !showSignDateStart"
                                   ng-change="checkDate(condition, 'signDateStart', 'signDateEnd')"
                                   is-open="showSignDateStart" close-text="关闭" modal-size="small" readonly>
                        </div>
                        <div class="form-group clearfix m-b-none">
                            <label class="control-label"></label>
                            <label class="control-label wave-line">~</label>
                        </div>
                        <div class="form-group clearfix">
                            <label class="control-label"></label>
                            <input type="text" class="form-control date-picker" ng-model="condition.signDateEnd"
                                   datepicker-popup="{{'yyyy-MM-dd'}}"
                                   ng-click="showSignDateEnd = !showSignDateEnd"
                                   ng-change="checkDate(condition, 'signDateStart', 'signDateEnd')"
                                   is-open="showSignDateEnd" close-text="关闭" modal-size="small" readonly>
                        </div>
                    </div>
                </div>
            </div>
            <div yb-col-config show-toolbar="toolbarConfig.showColConfig" ng-model="tableConfig" col-fixed="false"
                 has-check-col="true"></div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{tableConfig.scrollWidth}}">
                            <thead>
                            <tr>
                                <th width="40" class="text-center th-check border-l-none">
                                    <div yb-check-box yb-checked="markInfo.allChecked" yb-click="selectAll()"></div>
                                </th>
                                <th width="50" class="text-center th-check border-l-none">
                                    操作
                                </th>
                                <th ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                    width="{{itemCol.width}}" ng-click="toSort(tableConfig.tableCol, $index)"
                                    ng-show="!!itemCol.isShow">
                                    <div yb-thead-operate ng-model="itemCol"
                                         target-width="tableConfig.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="dataList.length > 0">
                        <table class="table-fixed border-none" width="{{tableConfig.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in dataList track by $index"
                                ng-class="{'row-selected': $index === markInfo.curRow}" ng-click="selectRow($index)">
                                <td width="40" class="text-center border-l-none">
                                    <div yb-check-box yb-checked="item.isChecked" yb-click="selectSingle(item)"></div>
                                </td>
                                <td width="50" class="text-center">
                                    <button type="button" class="btn btn-operate" ng-disbaled="!btnPermission.invoiceEdit" ng-click="edit(item, $index)">编辑</button>
                                </td>
                                <td class="spill-dots" ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                    width="{{itemCol.width}}"
                                    ng-show="!!itemCol.isShow"
                                    title="{{item[itemCol.dataField]}}">
                                    <div ng-switch="itemCol.type">
                                        <div ng-switch-when="click">
                                            <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)">
                                                {{item[itemCol.dataField]}}
                                            </a>
                                        </div>
                                        <div ng-switch-when="operate">
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                    ng-click="sign(item.id)"
                                                    ng-disabled="item.isSign === 1 || !btnPermission.invoiceSign"
                                                    title="{{!btnPermission.invoiceSign?'无权限执行此操作':''}}">签收
                                            </button>
                                        </div>
                                        <div ng-switch-default class="spill-dots">
                                            <span>{{item[itemCol.dataField]}}</span>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="dataList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area page-bar wrapper-y-sm clearfix">
                <div yb-page-info ng-model="pageInfo" yb-refresh="search()"></div>
            </div>
        </div>
        <div tab heading="详情" active="activeFlag[1]" ng-if="activeFlag[1]">
            <div class="row wrapper-y-sm">
                <div class="search-bar wrapper-none col-xs-12">
                    <div class="btn-group m-l-xs pull-right">
                        <button type="button" class="btn btn-default base-color" ng-click="detailPage.search()"
                                title="刷新">
                            <i class="yb-icon ico-refresh"></i>
                        </button>
                        <button type="button" class="btn btn-default base-color" title="配置表格列"
                                ng-click="detailPage.switchToolbar('ColConfig');">
                            <i class="yb-icon ico-set"></i>
                        </button>
                    </div>
                    <div class="input-group pull-right clearfix">
                        <input type="text" class="form-control txt-search" placeholder="发货通知单单号"
                               ng-model="detailPage.condition.deliveryNo">
                        <span class="input-group-addon cursor-pointer" ng-click="detailPage.search(1)">搜索</span>
                    </div>
                </div>
            </div>
            <div yb-col-config show-toolbar="detailPage.toolbarConfig.showColConfig" ng-model="detailPage.tableConfig"
                 col-fixed="false"
                 has-check-col="false"></div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{detailPage.tableConfig.scrollWidth}}">
                            <thead>
                            <tr>
                                <th ng-repeat="itemCol in detailPage.tableConfig.tableCol track by $index"
                                    width="{{itemCol.width}}"
                                    ng-click="detailPage.toSort(detailPage.tableConfig.tableCol, $index)"
                                    ng-show="!!itemCol.isShow">
                                    <div yb-thead-operate ng-model="itemCol"
                                         target-width="detailPage.tableConfig.scrollWidth"></div>
                                </th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="detailPage.dataList.length > 0">
                        <table class="table-fixed border-none" width="{{detailPage.tableConfig.scrollWidth}}">
                            <tbody>
                            <tr ng-repeat="item in detailPage.dataList track by $index"
                                ng-class="{'row-selected': $index === detailPage.markInfo.curRow}"
                                ng-click="detailPage.selectRow($index)">
                                <td class="spill-dots"
                                    ng-repeat="itemCol in detailPage.tableConfig.tableCol track by $index"
                                    width="{{itemCol.width}}"
                                    ng-show="!!itemCol.isShow"
                                    title="{{item[itemCol.dataField]}}">
                                    <div ng-switch="itemCol.type">
                                        <div ng-switch-when="click">
                                            <a class="btn-operate m-r-xs" ng-click="tdDetailClick(item, itemCol.clickFn)">
                                                {{item[itemCol.dataField]}}
                                            </a>
                                        </div>
                                        <div ng-switch-default>
                                            <span>{{item[itemCol.dataField]}}</span>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="detailPage.dataList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area page-bar wrapper-y-sm clearfix">
                <div yb-page-info ng-model="detailPage.pageInfo" yb-refresh="detailPage.search()"></div>
            </div>
        </div>

        <div tab heading="编辑" active="activeFlag[2]" ng-if="activeFlag[2]">
            <div class="main-area d-t-35 d-b-60">
                <form name="form" class="main-wrap form-horizontal single-col p-t clearfix" novalidate>
                    <div class="form-group">
                        <label class="col-xs-2 control-label">纸质发票号：</label>
                        <div class="col-xs-5 wrapper-none">
                            <input type="text" name="name" class="form-control" ng-model="invoiceObj.invoicePaperNo" maxlength="60">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-2 control-label"></label>
                        <div class="col-xs-5 wrapper-none">
                            <button type="button" class="btn btn-primary m-r-sm" ng-click="saveData()">
                                保存
                            </button>
                            <button type="button" class="btn btn-default" ng-click="changeTab(0)">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div tab heading="SAP历史数据同步" active="activeFlag[3]" ng-if="activeFlag[3]">
            <div class="main-area d-t-35 d-b-60">
                <form name="form" class="main-wrap form-horizontal single-col p-t clearfix" novalidate>
                    <div class="form-group" style="margin-bottom: 10px;" >
                        <label class="col-xs-2 control-label">同步时间开始：</label>
                        <div class="col-xs-5 wrapper-none" >
                            <input type="text" class="form-control date-picker" ng-model="syncTime.startDateStr"  maxlength="60"
                            datepicker-popup="{{'yyyy-MM-dd'}}"
                            ng-click="showOrderDateStart = !showOrderDateStart"
                            ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')"
                            is-open="showOrderDateStart" close-text="关闭" modal-size="small" readonly>
                        </div>
                       
                    </div>
                    <div class="form-group"  style="margin-bottom: 10px;" >
                        <label class="col-xs-2 control-label">同步时间结束：</label>
                        <div class="col-xs-5 wrapper-none" >
                            <input type="text" class="form-control date-picker" ng-model="syncTime.endDateStr"  maxlength="60"
                            datepicker-popup="{{'yyyy-MM-dd'}}"
                            ng-click="showOrderDateEnd = !showOrderDateEnd"
                            ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')"
                            is-open="showOrderDateEnd" close-text="关闭" modal-size="small" readonly>
                        </div>
             
                    </div>
                    <div class="form-group">
                        <label class="col-xs-2 control-label"></label>
                        <div class="col-xs-5 wrapper-none">
                            <button type="button" class="btn btn-primary m-r-sm" ng-click="syncSAPHistoryHandle()">
                                同步
                            </button>
                            <button type="button" class="btn btn-default" ng-click="changeTab(0)">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>